import { ActionBase } from "./Actions/ActionBase";
import { ActionSpawn } from "./Actions/spawn/ActionSpawn";
import * as Actions from "./Actions"
export class ActionRoute
{
    private static actionMap:Record<ActionKeys,ActionBase<Action>> ={
        spawn: new ActionSpawn,
        build: new Actions.ActionBuild,
        repair: new Actions.ActionRepair,
        upgrade: new Actions.ActionUpgrade,
        transfer: new Actions.ActionTransfer,
        harvest: new Actions.ActionHarvest,
        harvestEnergy:new Actions.ActionHarvestEnergy,
        withdraw: new Actions.ActionWithdraw,
        pickup: new Actions.ActionPickup,
        moveto: new Actions.ActionMoveTo,
        movetoPortal:new Actions.ActionMoveToCenterPortal,
        drop: new Actions.ActionDrop,
        accTransport: new Actions.ActionAccurateTransport,
        fill: new Actions.ActionFill,
        claim: new Actions.ActionClaim,
        reserve: new Actions.ActionReserve,
        attackController: new Actions.ActionAttackController,
        recycle:new Actions.ActionRecycling,
        unBoost:new Actions.ActionUnboost,
        foot:new Actions.ActionFootWork,
        movefill: new Actions.ActionMoveFill,
        // room Action
        placePlan: new Actions.ActionPlaceSite,
        towerDefend: new Actions.ActionTowerDefend,
        towerRepair: new Actions.ActionTowerRepair,
        towerHeal: new Actions.ActionTowerHeal,
        observe:new Actions.ActionObserve,

        // 一体机 Action
        attackBlue: new Actions.ActionIADAttackBlue,
        attackRed: new Actions.ActionIADAttackRed,

        // boost 相关Action
        clearLab: new Actions.ActionClearLab,
        fillLab: new Actions.ActionFillLab,
        react: new Actions.ActionLabReaction,
        renewCreep: new Actions.ActionRenewCreep,
        boostCreep: new Actions.ActionBoostCreep,
        creepdefend: new Actions.ActionCreepDefend,

        // 终端Action
        dealbuy: new Actions.ActionDealBuy,
        dealsell: new Actions.ActionDealSell,
        send: new Actions.ActionSend,

        // team 移动 Action
        lineMove: new Actions.ActionTeamLineMove,
        squareMove: new Actions.ActionTeamSquareMove,
        combatMove: new Actions.ActionTeamCombatMove,

        visualHostile: new Actions.ActionVisual,
        visualTeam: new Actions.ActionVisualTeam,
        escape: new Actions.ActionEscapeDanger
    }
    static Execute(action:IActionCMD)
    {
        const executer = this.actionMap[action.key];
        if(executer)
        {
            return executer.execute(action);
        }
        else
        {
            throw new Error(`未知的Action :${JSON.stringify(action.key)}`);
        }
    }
}